package com.shenxuchen.crm.web.controller;

import com.shenxuchen.crm.pojo.Page;
import com.shenxuchen.crm.service.TransactionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("tran")
public class TransactionController {
    @Resource
    private TransactionService transactionService;

    @GetMapping("getPage")
    public Page getPage(@RequestParam Map search,
                        @RequestParam(defaultValue = "1") Integer currentPage,
                        @RequestParam(defaultValue = "10") Integer rowsPerPage) {

        return transactionService.getPage(search, currentPage, rowsPerPage);
    }

    @GetMapping("chart")
    public List getChart() {
        return new ArrayList(){{
            add(new HashMap(){{
                put("value", 60);
                put("name", "07成交");
            }});
            add(new HashMap(){{
                put("value", 80);
                put("name", "01资质审查");
            }});
            add(new HashMap(){{
                put("value", 50);
                put("name", "08丢失的线索");
            }});
            add(new HashMap(){{
                put("value", 160);
                put("name", "09因竞争丢失关闭");
            }});
            add(new HashMap(){{
                put("value", 260);
                put("name", "02需求分析");
            }});
            add(new HashMap(){{
                put("value", 150);
                put("name", "05提案/报价");
            }});
            add(new HashMap(){{
                put("value", 10);
                put("name", "03价值建议");
            }});
            add(new HashMap(){{
                put("value", 130);
                put("name", "04确定决策者");
            }});
            add(new HashMap(){{
                put("value", 20);
                put("name", "06谈判/复审");
            }});
        }};
    }
}
